package edu.pku.sei.transformation.editor.controller.commands.node;

import org.eclipse.gef.commands.Command;

import edu.pku.sei.transformation.editor.model.Domain;
import edu.pku.sei.transformation.editor.model.Rule;

public class DomainDeleteCommand extends Command {
	private Domain domain;
	private Rule relation;

	public DomainDeleteCommand(Domain domain, Rule relation) {
		this.domain = domain;
		this.relation = relation;
	}

	@Override
	public boolean canExecute() {
		if (this.domain != null && this.relation != null) {
			return true;
		} else {
			return false;
		}
	}

	@Override
	public void execute() {
		this.relation.getDomains().remove(domain);
	}

	@Override
	public void undo() {
		this.relation.getDomains().add(domain);
	}
}
